home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Over 1,000 Windows 95 Programs
/
Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso
/
1256
/
convio.c_
/
convio.c
Wrap
C/C++ Source or Header
|
1997-04-18
|
3KB
|
153 lines
/* EasyCODE(C++) V5.1 02.03.1995 13:56:52 */
/* EasyCODE O
If=horizontal
LevelNumbers=no
LineNumbers=no
ScreenFont=Courier New,,80,9220,-11,0,400,0,0,0,0,0,0,3,2,1,49
PrinterFont=Courier New,,90,17414,-38,0,400,0,0,0,0,0,0,3,2,1,49
LastLevelId=15 */
/* EasyCODE ( 1
convio.c */
/* EasyCODE ( 8
Include */
#include "convio.h"
/* EasyCODE ) */
/* EasyCODE ( 9
ReadLine */
/* EasyCODE F */
BOOL ReadLine( char* inbuf, FILE* stream)
// Reads line from input file into buffer;
// Returns FALSE at EOF.
{
if (fgets(inbuf,I_BUFSIZE,stream) == NULL)
{
if (feof(stream))
{
return (TRUE);
}
else
{
perror("ReadLine error");
exit(1);
}
}
else
{
return (FALSE);
}
}
/* EasyCODE ) */
/* EasyCODE ( 10
StoreLine */
/* EasyCODE F */
void StoreLine( char* outbuf, FILE* stream)
// Write line from buffer to output file
{
if (fputs(outbuf,stream) == EOF)
{
perror("WriteLine error");
exit(1);
}
}
/* EasyCODE ) */
/* EasyCODE ( 11
OpenInput */
/* EasyCODE F */
FILE* OpenInput( char* name)
// Opens file for reading
{
FILE * stream;
if ((stream = fopen(name, "r")) == NULL)
{
perror("fopen failed on input file");
exit(1);
}
else
{
return (stream);
}
}
/* EasyCODE ) */
/* EasyCODE ( 12
TellPos */
/* EasyCODE F */
long TellPos(FILE* stream)
// Delivers actual position of file pointer
{
long position;
if ((position = ftell(stream)) == -1)
{
perror("TellPos error");
exit(1);
}
else
{
return (position);
}
}
/* EasyCODE ) */
/* EasyCODE ( 13
SeekPos */
/* EasyCODE F */
void SeekPos(long position, FILE* stream)
// Sets file pointer to given position
{
if (fseek(stream,position,0) == -1)
{
perror("SeekPos error");
exit(1);
}
}
/* EasyCODE ) */
/* EasyCODE ( 14
OpenOutput */
/* EasyCODE F */
FILE* OpenOutput( char* name)
// Opens file for writing
{
FILE * stream;
if ((stream = fopen(name, "w")) == NULL)
{
perror("fopen failed on output file");
exit(1);
}
else
{
return (stream);
}
}
/* EasyCODE ) */
/* EasyCODE ( 15
CloseFile */
/* EasyCODE F */
void CloseFile(FILE* stream)
// Closes file
{
fclose(stream);
}
/* EasyCODE ) */
/* EasyCODE ) */